home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************/
- /* (C) 1993,1994 R. NADE - M. GRANDCHAMP - All Rights Reserved */
- /*****************************************************************************/
- /* This source-code is NOT public domain nor Freeware, this is part of */
- /* 'The C Programming Package' which is Shareware. */
- /* If you use this code, please register and get a free Full-VGA version */
- /*****************************************************************************/
- /*--------------------*
- * CPPFIC2A.C *
- * FILE MANAGER *
- * other functions. *
- * second part 1/2 *
- *--------------------*/
-
- /* Included Files */
- # include <stdio.h>
- # include <io.h>
- # include <dos.h>
- # include <fcntl.h>
- # include <bios.h>
- # include <stdlib.h>
- # include <conio.h>
- # include <dir.h>
- # include <string.h>
- # include <alloc.h>
- # include <mem.h>
- # include <process.h>
- # include <conio.h>
-
- /* Global Variables */
- extern int bm,i,j,k,l,m,n,t,x,x1,x2,xm,y,y1,y2,ym,z,menu0,menu1,return1;
- extern int colour1,colour2,colour3,colour4,colour5,nbdisk,return2,return3,mode;
- extern int lline,linemax,choice,modif,pfdiv,pfserv,returning,recording;
- extern unsigned int ref,nbref,nbrep;
- extern long dep,depdiv;
- extern unsigned long nbbytes;
- extern unsigned char c0,c1,trashcan[],path[],nc1[],trashret[],filedir[];
- extern unsigned char work[],record[],saverep[],divers[];
- extern char *memory;
- extern struct ffblk ffblk;
- extern struct dfree dfree;
- extern struct text_info ti;
- extern struct directory{
- unsigned char name[9];
- unsigned char ext[4];
- unsigned char size[9];
- unsigned char attribut[2];
- unsigned char date[9];
- unsigned char time[6];
- } directory;
-
- /*---------------------------*
- * BACK TO DEFAULT DIRECTORY *
- *---------------------------*/
- void back_to_default_directory()
- {
- /* Get the path stored in the service file */
- i=open_working_file();
- if(i==0) return;
- dep+=40;
- lseek(pfserv,dep,0); read(pfserv,path,64);
- close(pfserv); pfserv=0;
- strncpy(nc1,path,2); nc1[2]=0x00;
- system(nc1); chdir(path);
- directory_change();
- }
- /*------------------------*
- * DEFINE WORK DIRECTORY *
- * files on which we work *
- *------------------------*/
- void define_the_work_directory()
- {
- blank_line_25(); textattr(colour3);
- gotoxy(1,25); cputs("Working Dir=");
- strcpy(trashcan,path);
- returning=get_or_change_a_word(13,25,64);
- if(returning>0){
- strcpy(path,trashret);
- /* We save the new path */
- i=open_working_file();
- if(i==0) return;
- dep+=40;
- lseek(pfserv,dep,0); write(pfserv,path,64);
- close(pfserv); pfserv=0;
- }
- }
- /*-------------------------*
- * DEFINE SYSTEM DIRECTORY *
- * program & config path *
- *-------------------------*/
- void define_the_system_directory()
- {
- i=message(" Program"," directory"," Are you sure"," you want to"," change it ? Y/N");
- if(i!=34) return;
- blank_line_25(); textattr(colour3);
- gotoxy(1,25); cputs("System Dir =");
- strcpy(trashcan,work);
- returning=get_or_change_a_word(13,25,64);
- if(returning>0){
- strcpy(work,trashret);
- /* Save the new path name */
- i=open_working_file();
- if(i==0) return;
- dep+=168;
- lseek(pfserv,dep,0); write(pfserv,work,64);
- close(pfserv); pfserv=0;
- }
- }
- /*----------------------------*
- * DEFINE RECORDING DIRECTORY *
- *----------------------------*/
- void define_recording_directory()
- {
- blank_line_25(); textattr(colour3);
- gotoxy(1,25); cputs("Record Rep =");
- strcpy(trashcan,record);
- returning=get_or_change_a_word(13,25,64);
- if(returning>0){
- strcpy(record,trashret);
- /* Save the new path name */
- i=open_working_file();
- if(i==0) return;
- dep+=104;
- lseek(pfserv,dep,0); write(pfserv,record,64);
- close(pfserv); pfserv=0;
- }
- }
- /*-------------------------------*
- * RECORDING OF SELECTED FILE *
- * Sub function of the directory *
- * manager (CPPFIC1B.C). *
- *-------------------------------*/
- void recording_of_the_selected_file()
- {
- if(recording==0) return;
- /* We reserved *divers to store the Copy DOS Command */
- /* at the beginning of the recording */
- strcpy(divers,"COPY ");
- /* Get the name of the file to be recorded */
- /* and the directory that has just been created */
- memcpy(&directory,memory,39); strcpy(trashcan,directory.name);
- /* Cut spaces at the end of the name */
- j=strlen(trashcan);
- for(i=j; i>-1; i--){
- c1=trashcan[i];
- if((c1==0x20)||(c1==0x00)) trashcan[i]=0x00;
- else break;
- }
- strcat(divers,trashcan); strcpy(trashcan,directory.ext);
- /* Cut spaces at the end of the extension */
- j=strlen(trashcan);
- for(i=j; i>-1; i--){
- c1=trashcan[i];
- if((c1==0x20)||(c1==0x00)) trashcan[i]=0x00;
- else break;
- }
- if(strlen(trashcan)>0){
- strcat(divers,"."); strcat(divers,trashcan);
- }
- strcat(divers," "); strcat(divers,saverep);
- nc1[0]=0x00; strcat(divers,nc1);
- gotoxy(1,24); system(divers);
- }
- /*------------------*
- * GET CURRENT MODE *
- *------------------*/
- void get_current_mode()
- {
- gettextinfo(&ti); mode=ti.currmode;
- if(ti.currmode==2) strcpy(trashcan,"N & B 80 col");
- if(ti.currmode==3) strcpy(trashcan,"Col. 80 col");
- if(ti.currmode==7) strcpy(trashcan,"Monoch 80 col");
- if(ti.currmode==64) strcpy(trashcan,"EGA/VGA 43/50");
- }
- /*----------------------------*
- * DISPLAY FREE SPACE ON DISK *
- *----------------------------*/
- void display_free_space_on_disk()
- {
- j=getdisk(); getdfree((j+1), &dfree);
- if(dfree.df_sclus==0xffff){
- warning(" Error during"," the call of"," Free Space"," on Drive.Click or"," Press any Key");
- return;
- }
- dep=(long) dfree.df_avail * (long) dfree.df_bsec * (long) dfree.df_sclus;
- ltoa(dep,trashcan,10); put_separators();
- right_justify_the_text(trashcan,12); strcat(trashret," bytes");
- strcpy(trashcan,"on the drive: "); j=getdisk();
- if(j==0) strcat(trashcan,"A:");
- if(j==1) strcat(trashcan,"B:");
- if(j==2) strcat(trashcan,"C:");
- if(j==3) strcat(trashcan,"D:");
- if(j==4) strcat(trashcan,"E:");
- if(j>4) strcat(trashcan,"testé");
- message(" Free Space",trashcan,trashret," Press any Key"," or click");
- }
- /*-----------------------*/
- /* End of the Module *//*---------------------------*/
-
-